﻿
using CSharpLibs.Annotations;

namespace System.IO
{
	[Builtin]
	public class FileInfo : FileSystemInfo
	{
		public FileInfo(string s)
			: base(s)
		{ ;}

		public FileInfo CopyTo(string destFileName)
		{
			File.Copy(base.FullPath, destFileName, false);
			return new FileInfo(destFileName);
		}

		public FileStream Create()
		{ return File.Create(base.FullPath); }

		public override void Delete()
		{ File.Delete(base.FullPath); }

		public void MoveTo(string destFileName)
		{ File.Move(base.FullPath, destFileName); }

		public FileStream Open(FileMode mode)
		{ return new FileStream(base.FullPath, mode, FileAccess.ReadWrite, FileShare.None); }

		public FileStream OpenRead()
		{ return new FileStream(base.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read); }

		public StreamReader OpenText()
		{ return new StreamReader(base.FullPath); }

		public FileStream OpenWrite()
		{ return new FileStream(base.FullPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None); }

		public DirectoryInfo Directory
		{
			get
			{
				String directoryName = this.DirectoryName;
				return new DirectoryInfo(directoryName);
			}
		}

		public String DirectoryName
		{
			get
			{
				String directoryName = Path.GetDirectoryName(base.FullPath);
				return directoryName;
			}
		}

		public override bool Exists
		{ get { return File.Exists(base.FullPath); } }

		public override string FullName
		{ get { return base.FullPath; } }

		public int Length
		{ get { return FileSystemInfo.FSAccessInfo.GetAccessInfo(base.FullPath).Length; } }

		public override string Name
		{ get { return Path.GetFileName(base.FullPath); } }
	}
}
